package com.ybwh.springboot1.controller;

import javax.validation.Valid;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ybwh.springboot1.common.ReturnT;
import com.ybwh.springboot1.model.vo.AreaVo;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

/**
 * swagger 例子
 *
 */
@Api(description="swagger 例子")
@Controller
@RequestMapping("/se")
public class SwaggerExampleController {

	@ApiOperation(value = "get请求例子", notes = "get请求例子notes")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "id", value = "用户ID", required = true, dataType = "long", paramType = "path"),
			@ApiImplicitParam(name = "code", value = "编码", required = true, dataType = "string", paramType = "query") })
	@ResponseBody
	@RequestMapping(value = "/ex1/{id}", method = RequestMethod.GET)
	public ReturnT<Object> example1(@PathVariable("id") Long id, @RequestParam("code") String code) {

		return ReturnT.successResp(null);
	}

	@ApiOperation(value = "post请求例子 query", notes = "get请求例子notes")
	@ResponseBody
	@RequestMapping(value = "/postQuery", method = RequestMethod.POST)
	public ReturnT<Object> postQuery(
			@ApiParam(value = "当前页") @RequestParam(value = "pageNum", required = false) Integer pageNum,
			@ApiParam(value = "每页显示数量") @RequestParam(value = "pageSize", required = false) Integer pageSize) {

		return ReturnT.successResp(null);
	}

	@ApiOperation(value = "post请求例子 form", notes = "get请求例子notes")
	@ApiImplicitParams({ @ApiImplicitParam(name = "pageNum", value = "当前页", dataType = "int", paramType = "form"),
			@ApiImplicitParam(name = "pageSize", value = "编码", dataType = "int", paramType = "form") })
	@ResponseBody
	@RequestMapping(value = "/postForm", method = RequestMethod.POST)
	public ReturnT<Object> postForm(@RequestParam(value = "pageNum") Integer pageNum,
			@RequestParam(value = "pageSize") Integer pageSize) {

		return ReturnT.successResp(null);
	}

	@ApiOperation(value = "post请求例子 application/json", notes = "get请求例子notes", code = 200)
	@ResponseBody
	@RequestMapping(value = "/postAppJson", method = RequestMethod.POST, consumes = "application/json")
	public ReturnT<AreaVo> postAppJson( @Valid @ApiParam(value = "地区信息", required = false) @RequestBody AreaVo areaVo) {

		return ReturnT.successResp(areaVo);
	}
	
	 
	
	
	@ApiOperation(value = "post请求例子 @ModelAttribute", notes = "get请求例子notes", code = 200)
	@ResponseBody
	@RequestMapping(value = "/postModelAttribute", method = RequestMethod.POST)
	public ReturnT<AreaVo> postModelAttribute(@ApiParam( required = false) @ModelAttribute AreaVo areaVo) {

		return ReturnT.successResp(areaVo);
	}

}
